#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <sys/time.h>
#include <algorithm>
//#include "src/google/profiler.h"

using namespace std;

vector<uint32_t> subseq;

int main(int32_t argc, char * argv[]){
    //ProfilerStart("missile.prof");
    FILE * f_in = fopen(argv[1], "rb");
    char line[BUFSIZ];
    int32_t read = 0;
    uint32_t att = 0;
    while((read = fread(line, sizeof(char), BUFSIZ, f_in))>0){
        for(int32_t i=0;i<read;i++){
            if(line[i]!='\n'){
                att = (att<<3) + (att<<1) + line[i] -'0';
            }else{
                vector<uint32_t>::iterator it = upper_bound(subseq.begin(), subseq.end(), att);
                if(it!=subseq.end()){
                    *it = att;
                }else{
                    subseq.push_back(att);
                }
                att = 0;
            }
        }
        line[0]=line[read-1];
    }
    //ProfilerStop();
    printf("%u\n", subseq.size());
    return 0;
}
